﻿using System;
using System.Windows.Forms;

namespace ChopPlugin
{
    /// <summary>
    /// Dialog for PDF configuration
    /// </summary>
    public partial class DlgPdfOptions : Telerik.WinControls.UI.RadForm
    {
        #region Properties
        private static PdfOptions pdfOptions;

        public PdfOptions Options { 
            get 
            {
                return pdfOptions;
            }
        }
        #endregion

        #region Constructor

        public DlgPdfOptions()
        {
            InitializeComponent();
            if (pdfOptions == null)
                pdfOptions = new PdfOptions();

            // Bind
            radSpinEditor1.Value = pdfOptions.StartPage;
            radRadioButtonLevel.ToggleState = pdfOptions.IndentByLevel ? Telerik.WinControls.Enumerations.ToggleState.On : Telerik.WinControls.Enumerations.ToggleState.Off;
            radRadioButtonCodeSize.ToggleState = pdfOptions.IndentByLevel ? Telerik.WinControls.Enumerations.ToggleState.Off : Telerik.WinControls.Enumerations.ToggleState.On;

            radCheckBoxSplit.Checked = pdfOptions.SplitLargeTable;
            radTextBoxBottom.Text = pdfOptions.BottomText;

            radCheckBoxNoNumber.Checked = pdfOptions.SuppressNumbering;
            radCheckBoxSmallFonts.Checked = pdfOptions.UseSmallFonts;
        }
        #endregion

        #region OK event

        private void radButtonOk_Click(object sender, EventArgs e)
        {
            pdfOptions.StartPage = (int)radSpinEditor1.Value;
            if (pdfOptions.StartPage < 1)
                pdfOptions.StartPage = 1;

            pdfOptions.BottomText = radTextBoxBottom.Text;
            pdfOptions.IndentByLevel = radRadioButtonLevel.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On;
            pdfOptions.SplitLargeTable = radCheckBoxSplit.Checked;
            pdfOptions.SuppressNumbering = radCheckBoxNoNumber.Checked;
            pdfOptions.UseSmallFonts = radCheckBoxSmallFonts.Checked;
            DialogResult = DialogResult.OK;
            this.Close();
        }
        #endregion

    }
}
